<?php

session_start();
$RandomStr = md5(md5(microtime().mt_rand(1111111,9999999).(06523034)));// md5 to generate the random string
$ResultStr = substr($RandomStr,0,6);//trim 6 digit
//$NewImage =imagecreatefromjpeg("img.jpg");//image create by existing image and as back ground
$NewImage =imagecreatetruecolor(75, 30); //(Panjang, Tinggi)
$LineColor = imagecolorallocate($NewImage,233,239,239);//line color
$TextColor = imagecolorallocate($NewImage, 255, 255, 255);//text color-white

imageline($NewImage,1,1,40,40,$LineColor);//create line 1 on image
imageline($NewImage,1,100,60,0,$LineColor);//create line 2 on image
imageline($NewImage,5, 1, 200, 50, $LineColor);
//imagettftext($im, 22, 0, 10, 35, $black, $font, $ResultStr);
imagestring($NewImage, 5, 15, 5, $ResultStr, $TextColor);// Draw a random string horizontally

$_SESSION['key'] = $ResultStr;// carry the data through session
header("Content-type: image/jpeg");// out out the image
imagejpeg($NewImage);//Output image to browser
imagedestroy($NewImage); //Clear output buffer.

?> 
